package com.yyk.yykywd.mvvm.adapter

import android.content.Context
import android.view.View
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yyk.yykywd.*
import com.yyk.yykywd.mvvm.entity.FullContractBean

/**
 * 文件描述：
 * Created by guo on 2019-11-19.
 */
class ReturnMoneyAdapter(private val context: Context,
                         private val type: String,
                         layoutResId: Int,
                         data: List<FullContractBean.Data>) : BaseQuickAdapter<FullContractBean.Data, BaseViewHolder>(layoutResId, data) {
    override fun convert(helper: BaseViewHolder, item: FullContractBean.Data) {
        helper.setText(R.id.tv_return_money_status, item.status_a)
        helper.setText(R.id.tv_founder, getPersonName(item.name, item.get_name))
        helper.setText(R.id.tv_create_time, getTime(item.name, item.create_time, item.create_time))

        val clHospital: ConstraintLayout = helper.getView(R.id.cl_hospital)
        val clAgent: ConstraintLayout = helper.getView(R.id.cl_agent)
        val tvAgent: TextView = helper.getView(R.id.tv_agent)
        val tvHospitalName: TextView = helper.getView(R.id.tv_hospital_name)
        val tvType: TextView = helper.getView(R.id.tv_type)
        if (type == FROM_RETURN_MONEY_AGENT) {
            clAgent.visibility = View.VISIBLE
            clHospital.visibility = View.GONE
            tvType.setBackgroundResource(R.color.col_f5c161)
            tvAgent.text = item.agentname
            helper.setText(R.id.tv_agent_contact, item.phone)
            helper.setText(R.id.tv_agent_region, item.area)
            helper.setText(R.id.tv_site_num, item.agency_count.toString())
        } else {
            clAgent.visibility = View.GONE
            clHospital.visibility = View.VISIBLE
            tvType.setBackgroundResource(R.color.col_68c3d4)
            tvHospitalName.text = item.hos_name
            helper.setText(R.id.tv_site_type, getSiteType(item.status))
            helper.setText(R.id.tv_number, item.order_code)
        }
    }

}